﻿<UserControl x:Class="Freshome.m.vws.Healtholds"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:f="clr-namespace:Freshome.m.vws">
    <UserControl.Resources>
        <f:Bool2Visible x:Key="b2v" />
    </UserControl.Resources>
    <Grid x:Name="topanel">
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition Height="Auto"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="100"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition MinWidth="100"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <DataGrid x:Name="dgh" ItemsSource="{Binding Path=P_holds}" IsReadOnly="{Binding Readonly}" Grid.Row="0" Grid.Column="0">
            <DataGrid.CommandBindings>
                <CommandBinding Command="ApplicationCommands.Delete" CanExecute="Delete_CanExecute" Executed="Delete_Executed" />
            </DataGrid.CommandBindings>
            <DataGrid.ContextMenu>
                <ContextMenu Visibility="{Binding Path=Enabled, Converter={StaticResource b2v}}">
                    <MenuItem Header="删除保健科目" Command="ApplicationCommands.Delete"></MenuItem>
                </ContextMenu>
            </DataGrid.ContextMenu>
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Path=Name}" Header="保健科目名称"
                                    MinWidth="100" MaxWidth="200" ToolTipService.ToolTip="2 - 10个字符"/>
                <DataGridTextColumn Binding="{Binding Path=Notes}" Header="保健科目说明" 
                                    MinWidth="200" MaxWidth="500" ToolTipService.ToolTip="0 - 50个字符"/>
            </DataGrid.Columns>
        </DataGrid>
        <TextBlock Grid.Row="1" Grid.Column="0">保健包括降压、护肤、减肥等科目，养生食材包括与科目相关的主料。</TextBlock>
        <GridSplitter Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Width="3" VerticalAlignment="Stretch" HorizontalAlignment="Center" ShowsPreview="True"></GridSplitter>
        <ScrollViewer Grid.Row="0" Grid.Column="2">
            <StackPanel>
                <DataGrid x:Name="dgr" ItemsSource="{Binding ElementName=dgh, Path=SelectedItem.Rights}" IsReadOnly="{Binding Readonly}">
                    <DataGrid.CommandBindings>
                        <CommandBinding Command="ApplicationCommands.Delete" CanExecute="Delete_CanExecute" Executed="Delete_Executed" />
                    </DataGrid.CommandBindings>
                    <DataGrid.ContextMenu>
                        <ContextMenu Visibility="{Binding Path=Enabled, Converter={StaticResource b2v}}">
                            <MenuItem Header="删除适宜主料" Command="ApplicationCommands.Delete"></MenuItem>
                        </ContextMenu>
                    </DataGrid.ContextMenu>
                    <DataGrid.Columns>
                        <DataGridComboBoxColumn x:Name="cbr" DisplayMemberPath="Value" SelectedValuePath="Key" SelectedValueBinding="{Binding Path=Jmx}"
                                        MinWidth="100" MaxWidth="200" Header="适宜主料" />
                        <DataGridTextColumn Binding="{Binding Path=Notes}" Header="适宜主料说明" 
                                    MinWidth="200" MaxWidth="500" ToolTipService.ToolTip="0 - 50个字符"/>
                    </DataGrid.Columns>
                </DataGrid>
                <DataGrid x:Name="dgw" ItemsSource="{Binding ElementName=dgh, Path=SelectedItem.Wrongs}" IsReadOnly="{Binding Readonly}">
                    <DataGrid.CommandBindings>
                        <CommandBinding Command="ApplicationCommands.Delete" CanExecute="Delete_CanExecute" Executed="Delete_Executed" />
                    </DataGrid.CommandBindings>
                    <DataGrid.ContextMenu>
                        <ContextMenu Visibility="{Binding Path=Enabled, Converter={StaticResource b2v}}">
                            <MenuItem Header="删除禁忌主料" Command="ApplicationCommands.Delete"></MenuItem>
                        </ContextMenu>
                    </DataGrid.ContextMenu>
                    <DataGrid.Columns>
                        <DataGridComboBoxColumn x:Name="cbw" DisplayMemberPath="Value" SelectedValuePath="Key" SelectedValueBinding="{Binding Path=Jmx}"
                                        MinWidth="100" MaxWidth="200" Header="禁忌主料"/>
                        <DataGridTextColumn Binding="{Binding Path=Notes}" Header="禁忌主料说明" 
                                    MinWidth="200" MaxWidth="500" ToolTipService.ToolTip="0 - 50个字符"/>
                    </DataGrid.Columns>
                </DataGrid>

            </StackPanel>
        </ScrollViewer>
        <Button Grid.Row="1" Grid.Column="2" Visibility="{Binding Path=Enabled, Converter={StaticResource b2v}}"
                Command="{Binding Path=Save}" Content="{Binding Path=Save.Name}" HorizontalAlignment="Right"></Button>
    </Grid>
</UserControl>
